<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function hasPermission($uri,$posid){
	if ($posid==0) return true; else {
		$permissions = array(array('mgmt\/addUser','mgmt\/addDeal'),
							 array('mgmt\/addDeal'),
							 array('mgmt\/allCategories','mgmt\/addCategory','mgmt\/allADeals','mgmt\/addAdeal','mgmt\/allComments', 'mgmt\/allBanners', 'mgmt\/addBanner', 'mgmt\/allComments')
							 );
		
		
		for ($j=0;$j<count($permissions[$posid-1]);$j++) {
					if (preg_match("/^".$permissions[$posid-1][$j]."/", $uri)!=0) {
						return true;
						
					}
				}
		

		for ($i=0;$i<3;$i++) 
			if (($i+1)!=$posid) {
			for ($j=0;$j<count($permissions[$i]);$j++) {
					if (preg_match("/^".$permissions[$i][$j]."/", $uri)!=0) {
						return false;
					}
				}
			}		
			
		return true;
	}
}
